package com.egoonet.websocket;

import java.util.HashSet;
import java.util.Set;

import javax.websocket.Endpoint;
import javax.websocket.server.ServerApplicationConfig;
import javax.websocket.server.ServerEndpointConfig;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WebSocketConfig implements ServerApplicationConfig {
	private final Logger logger = LoggerFactory.getLogger(WebSocketConfig.class);

	@Override
	public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> scanned) {
		logger.debug("开始扫描WebSocket类");
		Set<Class<?>> res = new HashSet<>();
		for(Class<?> cs: scanned){
			if(cs.getPackage().getName().startsWith("com.egoonet.websocket")){
				logger.debug("找到WebSocket Endpoint类[{}]", cs.getName());
				res.add(cs);
			}
		}
		
		return res;
	}

	@Override
	public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<? extends Endpoint>> arg0) {
		logger.debug("开始获取WebSocket Endpoint配置信息");
		Set<ServerEndpointConfig> res = new HashSet<>();
		
		return res;
	}
}
